package com.kunbo.cn.app.controller;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.kunbo.cn.app.entity.DeliveryNotice;
import com.kunbo.cn.app.service.DeliveryNoticeService;
import com.kunbo.cn.util.retu.BuildBean;
import com.kunbo.cn.util.retu.ResultBean;

@RestController
@RequestMapping("/deliveryNotice")
public class DeliveryNoticeController {
	
	
	@Autowired
	private DeliveryNoticeService service;
	
	
	
	@PostMapping("/saveNotice")
	public ResultBean<Boolean> saveNotice(
			@RequestParam("uuid")String uuid,
			@RequestParam("create_user_id")String create_user_id,
			@RequestParam("noticeCode")String noticeCode,
			@RequestParam("waybillsCode")String waybillsCode,
			@RequestParam("orderCode")String orderCode,
			@RequestParam("supplier")String supplier,
			@RequestParam("material")String material,
			@RequestParam("address")String address,
			@RequestParam("transport_unit")String transport_unit,
			@RequestParam("car_number")String car_number,
			@RequestParam("frid")String frid,
			@RequestParam("driver")String driver,
			@RequestParam("id_number")String id_number,
			@RequestParam("note")String note,
			@RequestParam("accruals")float accruals,
			@RequestParam("vehicle_authenticated_load")float vehicle_authenticated_load
			
			){
		ResultBean<Boolean>  result =  new ResultBean<Boolean>();
		return BuildBean.buildResult(result, "success", "error", service.saveNotice(noticeCode,waybillsCode,orderCode,supplier,material,address,transport_unit,car_number,frid,driver,id_number,note,accruals,vehicle_authenticated_load,uuid,create_user_id));
	}
	
	
	
	
	@PostMapping("/updNotice")
	public ResultBean<Boolean> updNotice(
			@RequestParam("id")Integer id,
			@RequestParam("notice_type")String notice_type,
			@RequestParam("noticeCode")String noticeCode,
			@RequestParam("waybillsCode")String waybillsCode,
			@RequestParam("orderCode")String orderCode,
			@RequestParam("supplier")String supplier,
			@RequestParam("material")String material,
			@RequestParam("address")String address,
			@RequestParam("transport_unit")String transport_unit,
			@RequestParam("car_number")String car_number,
			@RequestParam("frid")String frid,
			@RequestParam("driver")String driver,
			@RequestParam("id_number")String id_number,
			@RequestParam("note")String note,
			@RequestParam("accruals")float accruals,
			@RequestParam("vehicle_authenticated_load")float vehicle_authenticated_load
			
			){
		ResultBean<Boolean>  result =  new ResultBean<Boolean>();
		return BuildBean.buildResult(result, "success", "error", service.updNotice(id,notice_type,noticeCode,waybillsCode,orderCode,supplier,material,address,transport_unit,car_number,frid,driver,id_number,note,accruals,vehicle_authenticated_load));
	}
	
	
	
	
	@PostMapping("/selNotice")
	public ResultBean<DeliveryNotice> selNotice(
			@RequestParam("id")Integer id
			){
		ResultBean<DeliveryNotice>  result =  new ResultBean<DeliveryNotice>();
		return BuildBean.buildResult(result, "success", "error", service.selNotice(id));
	}
	
	
	
	@PostMapping("/selAllNotice")
	public ResultBean<List<Map<String,Object>>> selAllNotice(
			@RequestParam("wayBillUnit")Integer wayBillUnit,
			@RequestParam("notificationNumber")String notificationNumber,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean<List<Map<String,Object>>>  result = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.selAllNotice(notificationNumber,page,pageSize,wayBillUnit));
	}
	
	

}
